package Test;

public class WeiLai2 {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * @param root TreeNode类
     * @return int整型
     */
    static int res = 0;
    public int maxSum(TreeNode root) {
        if (root == null || root.left == null || root.right == null) return res;
        res++;
        maxSum(root.left);
        maxSum(root.right);
        return res;
    }

    public static void test(TreeNode node) {
        if (node == null || node.left == null || node.right == null) return;
        res++;
        test(node.left);
        test(node.right);
    }
}

class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;
    }
}
